<%@page import="java.util.List"%>
<%@page import="main.com.library.bean.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
	table{
		table-layout:fixed;
		text-align:center;
	}
	.pageBar a{
		color:blue;
		text-decoration:none;
	}
	.pageBar .red{
		color:red;
		text-decoration:underline;
	}
</style>
</head>
<body>
	欢迎
	<c:if test="${ sessionScope.loginUser.sex == '男'}" >
		欢迎${sessionScope.loginUser.realName }先生
	</c:if>
	<c:if test="${sessionScope.loginUser.sex ==  '女'}" >
		欢迎${sessionScope.loginUser.realName }女士
	</c:if>
	<c:if test="${sessionScope.loginUser.sex ==  ''}" >
		欢迎${sessionScope.loginUser.realName }
	</c:if>
	<img src="${loginUser.headImg}" width="80px" height="80px">
	<a href="insertBook.jsp">添加书本</a>
	<a href="book.html">测试异步请求</a>
	<form action="searchBook.do" method="GET">
		<input type="text" name="bookName" placeholder="请输入书名关键字" value="${bookName}">
		<input type="text" name="bookType" placeholder="请输入类型" value="${bookName}">
		<input type="text" name="bookWriter" placeholder="请输入作者" value="${bookName}">
		<input type="submit" value="查找">
	</form>
	<table width="800" border="1">
		<tr>
			<td>序号</td>
			<td>书名字</td>
			<td>类型</td>
			<td>作者</td>
			<td>价格</td>
			<td>出版时间</td>
			<td>封面</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${requestScope.page.data }" var="book" varStatus="stat">
			<tr>
				<td>${stat.count}</td>
				<td>${book.bookName }</td>
				<td>${book.bookType }</td>
				<td>${book.bookWriter }</td>
				<td>${book.bookPrice }</td>
				<td>${book.pubDate }</td>
				<td>
					<img src="${book.bookCover}" width="80" height="120">
				</td>
				<td><a href="deleteBook.do?bookId=${book.bookId}">删除</a>
					<a href="bookDetail.do?bookId=${book.bookId}">修改</a>
				</td>
			</tr>
		</c:forEach>
	</table>
	<div class="pageBar">
		<c:if test="${page.hasPrev}">
			<a href="searchBook.do?${url}&pageNum=1&pageSize=5">首页</a>
			<a href="searchBook.do?${url}&pageNum=${page.pageNum-1}&pageSize=5">上一页</a>
		</c:if>
		<c:forEach begin="1" end="${page.totalPages}" varStatus="stat">
			<c:if test="${page.pageNum == stat.count}">
				<a class="red" href="searchBook.do?${url}&pageNum=${stat.count}&pageSize=5">${stat.count}</a>
			</c:if>
			<c:if test="${page.pageNum != stat.count}">
				<a href="searchBook.do?${url}&pageNum=${stat.count}&pageSize=5">${stat.count}</a>
			</c:if>
		</c:forEach>
		<c:if test="${page.hasNext}">
			<a href="searchBook.do?${url}&pageNum=${page.pageNum+1}&pageSize=5">下一页</a>
			<a href="searchBook.do?${url}&pageNum=${page.totalPages}&pageSize=5">尾页</a>
		</c:if>
		总条数:${page.totalRows} 总页数 :${page.totalPages}
	</div>
</body>
</html>